home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / QuickDraw 3D / Samples / SampleCode / Plug-in - WireFrame Renderer / SR_Point.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  3.4 KB  |  137 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        SR_Point.c                                                 **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **     Purpose:     Point routines                                              **
  7.  **                                                                          **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1996 Apple Computer, Inc.  All rights reserved.         **
  11.  **                                                                          **
  12.  **                                                                          **
  13.  *****************************************************************************/
  14. #include <assert.h>
  15.  
  16. #include "QD3D.h"
  17.  
  18. #include "SR.h"
  19.  
  20.  
  21. /*===========================================================================*\
  22.  *
  23.  *    Routine:    SR_Geometry_Point()
  24.  *
  25.  *    Comments:    
  26.  *
  27. \*===========================================================================*/
  28.  
  29. TQ3Status SR_Geometry_Point(
  30.     TQ3ViewObject             view, 
  31.     TSRPrivate                 *srPrivate,
  32.     TQ3GeometryObject         point,
  33.     const TQ3PointData        *pointData)
  34. {
  35.     TQ3Boolean                highlightState;
  36.     TQ3XClipMaskState        clipMaskState;
  37.     TQ3ColorRGB                color;
  38.     
  39.     UNUSED(point);
  40.  
  41.     assert(view             != NULL);
  42.     assert(srPrivate    != NULL);
  43.     assert(pointData    != NULL);
  44.     
  45.     /*
  46.      *  Call the application's idle progress method, via the view.  If
  47.      *  the app's method returns kQ3Failure, then we don't go on.
  48.      */
  49.     if (SR_IdleProgress(view, srPrivate) == kQ3Failure) {
  50.         return (kQ3Success);
  51.     }
  52.  
  53.     if (srPrivate->drawRegion == NULL) {
  54.         return (kQ3Success);
  55.     }
  56.  
  57.     /*
  58.      *  Find out if we're clipped out or not. No reason to go any
  59.      *  further if the region is obscured or entirely off-screen. 
  60.      */
  61.     Q3XDrawRegion_GetClipFlags(srPrivate->drawRegion, &clipMaskState);
  62.     if (clipMaskState == kQ3XClipMaskNotExposed) {
  63.         return (kQ3Failure);
  64.     }
  65.  
  66.     /*
  67.      *  Lazy-evaluate the various transforms for the pipeline
  68.      */
  69.     if (SR_UpdatePipeline(srPrivate) == kQ3Failure) {
  70.         return (kQ3Failure);
  71.     }
  72.     
  73.     /*
  74.      *  Highlight state and  color are from the view, unless
  75.      *  overridden by the lineAttributeSet
  76.      */
  77.     highlightState    = srPrivate->viewHighlightState;
  78.     color             = srPrivate->viewDiffuseColor;
  79.  
  80.     /*
  81.      *  Check if we have a point attribute set.
  82.      *  If so, then see if we can get a color and highlight state
  83.      *  out of it. 
  84.      */
  85.     if (pointData->pointAttributeSet != NULL) {
  86.         TQ3XAttributeMask    attributeMask;
  87.         
  88.         attributeMask = Q3XAttributeSet_GetMask(pointData->pointAttributeSet);
  89.         
  90.         if (attributeMask & kQ3XAttributeMaskDiffuseColor) {
  91.             Q3AttributeSet_Get(
  92.                 pointData->pointAttributeSet, 
  93.                 kQ3AttributeTypeDiffuseColor, 
  94.                 &color);
  95.         }
  96.  
  97.         if (attributeMask & kQ3XAttributeMaskHighlightState) {
  98.             Q3AttributeSet_Get(
  99.                 pointData->pointAttributeSet, 
  100.                 kQ3AttributeTypeHighlightState, 
  101.                 &highlightState);
  102.         }
  103.     }
  104.  
  105.     /*
  106.      *  If we're highlighting, then see if we can get a highlight color
  107.      *  out of the view's attribute set. Use that as the color, if it's there.
  108.      */
  109.     if ((highlightState == kQ3True) &&
  110.         (srPrivate->viewHighlightAttributeSet != NULL)) {
  111.         TQ3XAttributeMask    attributeMask;
  112.         
  113.         attributeMask = Q3XAttributeSet_GetMask(
  114.                             srPrivate->viewHighlightAttributeSet);
  115.                             
  116.         if (attributeMask & kQ3XAttributeMaskDiffuseColor) {
  117.             Q3AttributeSet_Get( 
  118.                 srPrivate->viewHighlightAttributeSet, 
  119.                 kQ3AttributeTypeDiffuseColor, 
  120.                 &color);
  121.         }
  122.     }
  123.     
  124.     if (SR_PointPipe(
  125.             srPrivate, 
  126.             (TQ3Point3D *) &pointData->point, 
  127.             1, 
  128.             sizeof(TQ3Vertex3D),
  129.             &color,
  130.             NULL,
  131.             DO_POLYLINE) == kQ3Failure) {
  132.         return (kQ3Failure);
  133.     }
  134.                    
  135.     return (kQ3Success);
  136. }
  137.